package com.lm.controller;

import com.github.pagehelper.PageInfo;
import com.lm.model.RespBean;
import com.lm.model.TEntityTeaching;
import com.lm.service.TeachingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName TeachingController
 * @Description TODO
 * @Author wn
 * @Date 2019/3/31 16:37
 * @Version 1.0
 **/
@RestController
@RequestMapping("/teaching")
public class TeachingController {
    @Autowired
    private TeachingService teachingService;


    @GetMapping("/list")
    public Map<String,Object> getList(Integer pageSize, Integer pageNumber, String planId) {
        PageInfo pageInfo = teachingService.getList(pageSize,pageNumber,planId);
        Map<String,Object> map = new HashMap<>();
        map.put("list",pageInfo.getList());
        map.put("total",pageInfo.getTotal());
        return map;
    }

    @PostMapping("/entity")
    public RespBean addEntity(@RequestBody TEntityTeaching teaching) {
        Integer i = teachingService.addEntity(teaching);
        return i != 0 ? new RespBean("success","添加成功") : new RespBean("error","添加失败");
    }
}
